using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using AtletIS.DomainModel.Entities.Main;

namespace AtletIS.Database.Mapping.Main
{
    public class ExtTextMap : EntityTypeConfiguration<ExtText>
    {
        public ExtTextMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Header)
                .HasMaxLength(100);

            this.Property(t => t.Text1)
                .HasMaxLength(200);

            this.Property(t => t.Text2)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("ExtTexts");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.PerformanceId).HasColumnName("PerformanceId");
            this.Property(t => t.DisciplineListId).HasColumnName("DisciplineListId");
            this.Property(t => t.Header).HasColumnName("Header");
            this.Property(t => t.Num1).HasColumnName("Num1");
            this.Property(t => t.Num2).HasColumnName("Num2");
            this.Property(t => t.Text1).HasColumnName("Text1");
            this.Property(t => t.Text2).HasColumnName("Text2");
            this.Property(t => t.Active).HasColumnName("Active");
            this.Property(t => t.Sync).HasColumnName("Sync");
            this.Property(t => t.WebId).HasColumnName("WebId");
            this.Property(t => t.Modified).HasColumnName("Modified");

            // Relationships
            this.HasOptional(t => t.DisciplineList)
                .WithMany(t => t.ExtTexts)
                .HasForeignKey(d => d.DisciplineListId);
            this.HasOptional(t => t.Performance)
                .WithMany(t => t.ExtTexts)
                .HasForeignKey(d => d.PerformanceId);

        }
    }
}
